{% extends "admin.html" %}

{% block title %}The Living History: Users{% endblock %}

{% block display %}

		<h2>Users:</h2>
		<table>
			<tr>
				<th>Username</th>
				<th>Google username</th>
				<th>Groups</th>
			</tr>
		{% for user in lh_users %}
			<tr>
				<td>{{ user.username }}</td>
				<td>{{ user.google_user.nickname }}</td>
				<td>{% for group in user.groups %}{{group.name}}, {% endfor %}</td>
				<td><a href="/admin/editUser/{{user.username}}">Edit</a></td>
			</tr>
		{% endfor %}
		</table>
		
		<p>
		<h2>Add user:</h2>
		<form action="/admin/addUser" method="post">
		<table>
	      <tr>
		    <td>Username:</td>
			<td><input type="Text" name="username" size="25"></td>
		  </tr>
		  <tr>
			  <td>Google username:</td>
			  <td><input type="Text" name="google_username"> @gmail.com</td>
		  </tr>
		  <tr>
		  	<td>Groups:</td>
			<td>
				<select name="groups" multiple>
 				{% for group in groups %}
					<option value="{{ group.name }}" 
					{% for usergroup in user.groups %} 
						{% ifequal group usergroup %}selected{% endifequal %}
					{% endfor %}
					>{{ group.name }}</option>
				{% endfor %}
				</select>
			</td>
		  <tr>
			<td>Permissions:</td>
			<td>[reserved]</td>
		  </tr>
		  <tr>
		  <td align="center" colspan="2"><input type="Submit" name="add" value="Add user"></td>
		  </tr>
		</table>
		</form>
		</p>

{% endblock %}